#ifndef CLIENT_H
#define CLIENT_H
#include <custom_head.h>
#include "util.h"
#include "toml.h"

#define JWT_LEN 244
#define MAX_SIZE 100 * 1024 * 1024
typedef struct TLV_s {
  ssize_t len;
  char data[4096];
  char jwt[JWT_LEN+1];
} TLV;

typedef struct Para_s {
  int netfd;
  char *cmd;
  char **path;
} Para;

void epoll_add(int epfd, int fd);
int tcp_init(char *ip, char *port);

// ssize_t recvn(int fd, void* buf, ssize_t len);
ssize_t recv_tlv(int netfd, TLV *tlv);
ssize_t send_tlv(int netfd, const void *buf, ssize_t len);
//void send_tlv(int sockfd, void *buf, ssize_t len);

//int deal_command(int netfd, char *cmd);
/* 命令调度：根据命令判断走短命令 / 长命令 */
int  deal_command(int shortfd, char* ip, char* longPort, char* cmd);

void *cd_c(void *arg);
void *ls_c(void *arg);

void *puts_c(void *arg);
void *gets_c(void *arg);

void *remove_c(void *arg);
void *pwd_c(void *arg);

void *mkdir_c(void *arg);
void *rmdir_c(void *arg);

void *login_c(void *arg);
void *sign_up_c(void *arg);
void *tree_c(void *arg);
/* ---- 子线程入口: puts/gets ---- */
void* puts_thread(void* arg);
void* gets_thread(void* arg);
#endif
